#include "../../common/rabbitmq.hpp"
#include <gflags/gflags.h>

DEFINE_bool(run_mode, false, "程序的运行模式， false-调试； true-发布");
DEFINE_string(log_file, "", "发布模式下，用于指定日志的输出文件");
DEFINE_int32(log_level, 0, "发布模式下，用于指定日志输出等级");

DEFINE_string(user, "root", "这是RabbitMQ用户");
DEFINE_string(password, "123456", "这是RabbitMQ用户密码");
DEFINE_string(host, "127.0.0.1:5672", "这是RabbitMQ服务器的地址信息, 格式： 127.0.0.1:5672");


int main(int argc, char* argv[])
{
    google::ParseCommandLineFlags(&argc, &argv, true);
    ChatSystem::InitLogger(FLAGS_run_mode, FLAGS_log_file, FLAGS_log_level);

    MQClient client(FLAGS_user, FLAGS_password, FLAGS_host);
    client.declareComponents("test_exchange", "test_queue");
    client.consume("test_queue", [](const char* body, size_t sz){
        std::string msg;
        msg.assign(body, sz);
        LOG_INFO("订阅的消息：{}", msg);
    });
    std::this_thread::sleep_for(std::chrono::seconds(60));
    return 0;
}